﻿using System;

namespace Peter.DataAccess.Sqlite
{
   /// <summary>
   /// Holds information about a sqlite column.
   /// </summary>
   public class SqliteColumn
   {
      /// <summary>
      /// Gets or Sets the column name.
      /// </summary>
      public string Name { get; set; }

      /// <summary>
      /// Gets or Sets the column type.
      /// </summary>
      public SqliteColumnType DataType { get; set; }

      /// <summary>
      /// Converts the given data type to a string.
      /// </summary>
      /// <param name="dataType"></param>
      /// <returns></returns>
      public static SqliteColumnType StringToDataType (string dataType)
      {
         if (dataType.Equals (SqliteColumnType.Blob.ToString (), StringComparison.CurrentCultureIgnoreCase))
            return SqliteColumnType.Blob;
         if (dataType.Equals (SqliteColumnType.Integer.ToString (), StringComparison.CurrentCultureIgnoreCase))
            return SqliteColumnType.Integer;
         if (dataType.Equals (SqliteColumnType.Float.ToString (), StringComparison.CurrentCultureIgnoreCase))
            return SqliteColumnType.Float;
         if (dataType.Equals (SqliteColumnType.IntegerPrimaryKey.ToString (), StringComparison.CurrentCultureIgnoreCase))
            return SqliteColumnType.IntegerPrimaryKey;
         return SqliteColumnType.Text;
      }
   }
}
